//
//  BK_Calendar_WeekdayCell.m
//  bestkeep
//
//  Created by TOPTEAM on 2017/2/28.
//  Copyright © 2017年 utouu. All rights reserved.
//

#import "BK_Calendar_WeekdayCell.h"

@implementation BK_Calendar_WeekdayCell
{
    UILabel *_textLab;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initialize];
    }
    return self;
}

- (void)initialize
{
    _textLab = [[UILabel alloc] init];
    _textLab.font = [UIFont systemFontOfSize:12];
    _textLab.textAlignment = NSTextAlignmentCenter;
    _textLab.numberOfLines = 1;
    [self.contentView addSubview:_textLab];
    
    [self makeConstraints];
}

- (void)makeConstraints{
    _textLab.translatesAutoresizingMaskIntoConstraints = NO;
    NSLayoutConstraint *textLabTopConstraint = [NSLayoutConstraint constraintWithItem:_textLab attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1 constant:0];
    NSLayoutConstraint *textLabLeftConstraint = [NSLayoutConstraint constraintWithItem:_textLab attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1 constant:0];
    NSLayoutConstraint *textLabRightConstraint = [NSLayoutConstraint constraintWithItem:_textLab attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1 constant:0];
    NSLayoutConstraint *textLabBottomConstraint = [NSLayoutConstraint constraintWithItem:_textLab attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1 constant:0];
    
    [self.contentView addConstraints:@[textLabTopConstraint, textLabLeftConstraint, textLabBottomConstraint, textLabRightConstraint]];
}

- (void)fillData:(id)data
{
    if (!data) {
        return;
    }
    _textLab.text = data[@"text"];
    _textLab.textColor = [data[@"shouldRed"] isEqualToString:@"1"] ? [UIColor redColor] : [UIColor grayColor];
}

@end

